
{extend name="Public/layout2.html"}
{block name='body'}
<blockquote class="layui-elem-quote">
    <span class="layui-breadcrumb">
  					<a href="../">首页</a>
  					<a><cite>加班休息</cite></a>
					</span>
</blockquote>
<fieldset class="layui-elem-field layui-field-title">
    <legend>加班休息</legend>
</fieldset>

<div class="layui-form-pane" style="margin-top: 15px;">

    <div class="layui-form-item">

        <label class="layui-form-label">范围选择</label>
        <div class="layui-input-inline">
            <input class="layui-input" placeholder="开始日" id="LAY_demorange_s">
        </div>
        <div class="layui-input-inline">
            <input class="layui-input" placeholder="截止日" id="LAY_demorange_e">
        </div>
        <button class="layui-btn"onclick="serbytime()" ><i class="layui-icon">&#xe615; </i>搜索</button>
        <button class="layui-btn"onclick="refreshTable()" ><i class="layui-icon">&#xe63d; </i>刷新</button>
        <button class="layui-btn" onclick="addlayer()"><i class="layui-icon">&#xe609; </i>新增你说好不好</button>
    </div>
    <table class="layui-table" id="table1" style="margin:15px">

        <thead>
        <tr>
            <th>id</th>
            <th>人员</th>
            <th>开始时间</th>
            <th>结束时间</th>
            <th>时长</th>
            <th>类型</th>
            <th>审核</th>
            <th>备注</th>
            <th>操作</th>
        </tr>
        </thead>

    </table>
</div>



{/block}
{block name="jslink"}
{__block__}
<script type="text/javascript">
    function addlayer() {
        var addgs = layer.open({
            area: ['1200px', '600px'],
            type: 2,
            content: "{:url('index/level/addlevel')}"
        });
    }

    function refreshTable() {
        table.settings()[0].ajax.data=null;
        table.ajax.reload(null, false);
    }
    function del(id) {
        var url = "{:url('index/level/deletebyid')}";
        var data = {
            id: id
        };
        $.post(url, data, function (data) {
            layer.msg(data.msg);
            refreshTable();
        })
    }
    function pendrecord(id) {
        var url = "{:url('index/Level/pendbyid')}";
        var data = {
            id: id
        };


        $.post(url, data, function (data) {
            layer.msg(data.msg);
            refreshTable();
        })
    }
</script>

<script type="text/javascript">
    var table=null;
    $(function () {
           table=$('#table1').DataTable({
              "order": [],//必须加这个.不加表格的排序是自动的,和数据排序无关
              'ajax':{"url":"{:url('index/level/getlist')}"},
              'columns':[
                  {'data':'id'},
                  {'data':'member.name', "defaultContent": "无"},//如果内容为空,不设置默认内容的话会报错
                  {'data':'starttime'},
                  {'data':'stoptime'},
                  {'data':'duration'},
                  {'data':'leixing'},
                  {'data':'pend'},
                  {'data':'beizhu'},
                  {'data':null},
              ],
               'columnDefs':[
                   {
                       'targets': -1,
                       'data': null,
                       'width':'180px',
                       "render": function (data, type, row, meta) {
                           var ss = data;
                           var id = '"' + row.id + '"';
                           var fun2 = "del(" + id + ")";
                           var fun3 = "pendrecord(" + id + ")";
                           return '<div class="layui-btn-group">' +
                               '  <button class="layui-btn-small layui-btn  layui-btn-danger" onclick=' + fun2 + ' > <i class="layui-icon">&#xe640;</i> 删除</button>' +
                               '  <button class="layui-btn-small layui-btn" onclick=' + fun3 + ' > <i class="layui-icon">&#xe618;</i> 审核</button>' +
                               '</div>';
                   }}
               ]
          })
    });
    function serbytime() {
        var stime=$('#LAY_demorange_s').val();
        var dtime=$('#LAY_demorange_e').val();
        var param2 = {
            "stime": stime,
            "dtime": dtime
        };
        table.settings()[0].ajax.data=param2;
//        table.ajax.params=param2;
        table.ajax.reload();
    }

    
</script>
<script>
    $(function () {

        var laydate = layui.laydate;

        var start = {
            format: 'YYYY-MM-DD ', //日期格式
            max: '2099-06-16 23:59:59'

            , istoday: false
            , choose: function (datas) {
                end.min = datas; //开始日选好后，重置结束日的最小日期
                end.start = datas //将结束日的初始值设定为开始日
            }
        };

        var end = {
            format: 'YYYY-MM-DD ', //日期格式
            min: laydate.now()

            , max: '2099-06-16 23:59:59'
            , istoday: false
            , choose: function (datas) {
                start.max = datas; //结束日选好后，重置开始日的最大日期
            }
        };

        document.getElementById('LAY_demorange_s').onclick = function () {
            start.elem = this;
            laydate(start);
        };
        document.getElementById('LAY_demorange_e').onclick = function () {
            end.elem = this;
            laydate(end);
        }
    });


</script>

{/block}